#include "Common.h"
#include "Renderable.h"
#include "RenderQueue.h"
#include "Scene.h"

Renderable::Renderable()
	: mSceneID(INVALID_SCENE_ID)
	, mRenderGroup(RenderQueue::ERQG_World)
{
}

Renderable::~Renderable()
{
}

void Renderable::AddToScene(Scene* scene)
{
	scene->AddToScene(this);

	// build drawlist linkage.
	RenderQueue* renderQueue = scene->getRenderQueue();
	renderQueue->AddRenderable(this);
}

void Renderable::RemoveFromScene(Scene* scene)
{
	scene->RemoveFromScene(this);

	// remove drawlist linkage.
	for (DrawListElementLinkList::iterator it(mLinkList.begin()), end(mLinkList.end()); it != end; it++)
		(*it)->Delete();
	mLinkList.clear();
}

void Renderable::UpdateSceneID(size_t id)
{
	mSceneID = id;
}